#!/usr/bin/python3
# -*- coding: utf-8 -*-
import requests


class RequestHandler:
    def __init__(self):
        """session管理器"""
        self.session = requests.session()

    def visit(self, method, url,  params=None, data=None, json=None, headers=None, **kwargs):
        return self.session.request(method, url, params=params, data=data, json=json, headers=headers, **kwargs)

    def close_session(self):
        """关闭session"""
        self.session.close()


if __name__ == '__main__':
    # 以下是测试代码
    # post请求接口
    url = 'http://59.56.77.23:8202/user/detail'
    params = {
        "userId": "4"
    }
    req = RequestHandler()
    login_res = req.visit("get", url, params=params)
    print(login_res.text)
